|
|
|
| |
|
|
|
|
cDBName = "c:\tysdbvb5\source\data\books5.mdb" |
|
|
|
|
|
|
|
|
This would allow us to move and store our programs in any directory without having to worry about changing the pointer to our database. |
|
|
|
|
|
|
|
|
|
|
Place the following code in the general declarations section of your form: |
|
|
|
|
|
|
|
|
Public Sub OpenDB()
Dim cDBName As String ' declare a string variable
'
cDBName = "c:\tysdbvb5\source\data\books5.mdb" ' point to database
'
Data1.DatabaseName = cDBName ' set database property
'
Data1.Refresh ' update data control properties
End Sub |
|
|
|
|
| |
|
|
|
|
When you enter Visual Basic program code, Visual Basic looks for typing errors automatically. Each time you press the Enter key, Visual Basic scans the line, capitalizes Visual Basic reserved words (if everything has been typed correctly), adds spaces between the equal signs, and so on. When you enter code, don't try to capitalize or space properly; let Visual Basic do it for you. That way, if you finish a line and press the Enter key and then notice that Visual Basic has not "edited" for you, you'll know that there is probably something on that line that Visual Basic didn't understand. Now you'll catch your typing errors as you code! |
|
|
|
|
|
|
|
|
|
|
The last line in the procedure forces the data control to update all the new properties that have been set in the routine. Any time you use Visual Basic code to change data control properties, you must invoke the Refresh method to update the data control. This is just one of the data control methods. Other data control methods are discussed throughout today's lesson. |
|
|
|
|
|